home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
015a
/
qbfree71.zip
/
FREE71.BAS
next >
Wrap
BASIC Source File
|
1991-02-16
|
6KB
|
172 lines
' Free71.Bas 02-16-91 Multi-drive free disk space utility.
' Copyright 1991 by Thomas E. McCormick. All rights reserved.
' Placed into the public domain by the author.
' Source may be used in part or in total without restriction.
' Requires Crescent Software QuickPak Professional Library.
' Uses InterruptX under Microsoft BASIC 7.1 PDS:...QBX.LIB.
' Reports media data, total space, and free disk space on
' 1 or more drives by displaying one line per drive. The
' drive(s) specifier may or may not have colons or spaces.
' Traps/reports drive not ready, invalid drive letter, etc..
' -------------------------------------------------------------
' Compile and Link example batch file:
' @Echo OFF
' Rem ClFree71.Bat 02-16-91 TEM (C)ompile and (L)ink Free71.Bas
' bc free71 /o/s;
' link /noe/seg:400 free71+nofltin+nocom+nograph+nolpt+noedit+smallerr,,nul,qbx+d:\bc7\pro\libs7\pro7;
' -------------------------------------------------------------
' Example: To see free space on drives C:, D:, and E:, enter:
' free cde
' or free c d e
' or free c:d:e:
' or free c: d: e:
' The output may be redirected.
' -------------------------------------------------------------
'----- QuickPAK declarations: let compiler syntax for you...
DECLARE FUNCTION DiskRoom& (Q.Drive$)
DECLARE FUNCTION DiskSize& (Q.Drive$)
DECLARE FUNCTION DOSError ()
DECLARE FUNCTION GetDrive% ()
DECLARE FUNCTION ReadTest% (Q.Drive$)
DECLARE SUB BPrint (Lin$)
'----- Define the type needed for InterruptX -----
TYPE RegTypeX
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
ds AS INTEGER
es AS INTEGER
END TYPE
DECLARE SUB InterruptX (intnum AS INTEGER,inreg AS RegTypeX, outreg AS RegTypeX)
DIM regs AS RegTypeX
Begin:
DriveList$ = COMMAND$
IF DriveList$ = "" THEN
DriveList$ = CHR$(GetDrive%) 'Get default drive letter
END IF
Clen% = LEN(DriveList$)
DoCmdTail:
FOR DriveLetters% = 1 TO Clen% 'Drive(s) were specified
C$ = MID$(DriveList$, DriveLetters%, 1) 'COMMAND$ is upper case
Drive% = INSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ", C$)
IF Drive% > 0 THEN 'Skip colons, spaces, etc
Q.Drive$ = C$ 'The drive letter uppercase
DriveReady% = ReadTest%(Q.Drive$)
IF NOT DriveReady% THEN 'Invalid, door open, etc.
DriveDesc$ = "????? " 'Report it anyway
GOSUB Q.ReportDiskInfo
GOTO NextDrive
END IF
Q.FreeSpace& = DiskRoom&(Q.Drive$)
Q.TotalSpace& = DiskSize&(Q.Drive$)
IF Q.TotalSpace& > 10000 THEN 'Prevent divide by zero
Temp& = (Q.FreeSpace& * 100)
Q.FreePct& = (Temp& \ Q.TotalSpace&)
END IF
GOSUB Q.GetMediaType 'For specific desc comment
GOSUB Q.ReportDiskInfo 'Output 1 line per drive
END IF
NextDrive:
NEXT DriveLetters%
SYSTEM
'------
Q.GetMediaType: 'get disk ID byte
regs.ax = &H1C00
regs.dx = ASC(Q.Drive$) - 64 'A=0, B=1, etc.
30 CALL InterruptX(&H21, regs, regs) 'Uses QBX.LIB
31 DEF SEG = regs.ds
Q.MediaIDByte% = PEEK(regs.bx)
DEF SEG
DriveDesc$ = " " 'In case unidentified
SELECT CASE Q.MediaIDByte%
CASE &HF0
IF Q.TotalSpace& > 1300000 THEN
DriveDesc$ = "3" + CHR$(171) + " HD " + Dk$
END IF
IF Q.TotalSpace& > 2500000 THEN
DriveDesc$ = "3" + CHR$(171) + " XD " + Dk$
END IF
CASE &HF8
DriveDesc$ = "Fixed "
CASE &HF9
IF Q.TotalSpace& > 150000 THEN
DriveDesc$ = "5" + CHR$(172) + " SS " + Dk$
END IF
IF Q.TotalSpace& > 170000 THEN
DriveDesc$ = "5" + CHR$(172) + " SS " + Dk$
END IF
IF Q.TotalSpace& > 300000 THEN
DriveDesc$ = "5" + CHR$(172) + " SD " + Dk$
END IF
IF Q.TotalSpace& > 340000 THEN
DriveDesc$ = "5" + CHR$(172) + " SD " + Dk$
END IF
IF Q.TotalSpace& > 700000 THEN
DriveDesc$ = "3" + CHR$(171) + " DD " + Dk$
END IF
IF Q.TotalSpace& > 900000 THEN
DriveDesc$ = "5" + CHR$(172) + " HD " + Dk$
END IF
CASE &HFD
DriveDesc$ = "5" + CHR$(172) + " SD " + Dk$
CASE ELSE
END SELECT
RETURN
'------
Q.ReportDiskInfo:
Lin$ = DriveDesc$ + "Drive " + Q.Drive$ + ": has "
S$ = STR$(Q.FreeSpace&)
GOSUB W.Commatize
S$ = SPACE$(11) + S$ ' Right justify
S$ = RIGHT$(S$, 11)
Lin$ = Lin$ + S$ + " bytes free ("
S$ = STR$(Q.FreePct&)
GOSUB W.Commatize
S$ = " " + S$
S$ = RIGHT$(S$, 3)
Lin$ = Lin$ + S$ + " %) " + CHR$(13) + CHR$(10)
BPrint(Lin$)
Q.FreeSpace& = 0 ' Clean up in case next drive letter invalid
Q.FreePct& = 0
RETURN
'------
W.Commatize:
'-----------------------------------------------------------------------
'Call with digital string in S$, returns S$ containing commas (longer!)
'-----------------------------------------------------------------------
S$ = LTRIM$(S$): S$ = SPACE$(12) + S$: S$ = RIGHT$(S$, 12)
S2$ = LEFT$(S$, 3) + "," + MID$(S$, 4, 3) + "," + MID$(S$, 7, 3)
S2$ = S2$ + "," + RIGHT$(S$, 3) ' Now length is 15
FOR Temp% = 1 TO LEN(S2$)
C$ = MID$(S2$, Temp%, 1) ' One char at a time.
Num% = INSTR("0123456789-", C$) ' Look for numeric char
IF (Num% <> 0) THEN ' Drop until 1st one
S$ = RIGHT$(S2$, (16 - Temp%)) ' Then keep only numeric
EXIT FOR ' ...and quit loop
END IF
NEXT Temp%
W.Commatize.Exit:
RETURN
'------